{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "metafile = open('meta_nota.csv')\n",
    "data = []\n",
    "for line in metafile:\n",
    "    attr = line.rstrip().split('\\t')\n",
    "    assert(len(attr) == 9)\n",
    "    name, paper, code, inst, date, p1, p2, p3, p4 = attr\n",
    "    score = float(p1) + float(p2) + float(p3) + float(p4)\n",
    "    item = {'meta': [name, paper, code, inst, date, p1, p2, p3, p4], 'score': score}\n",
    "    data.append(item)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "data.sort(key=lambda x: x['score'], reverse=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from bs4 import BeautifulSoup"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "rank = 0\n",
    "s = ''\n",
    "for item in data:\n",
    "    name, paper, code, inst, date, p1, p2, p3, p4 = item['meta']\n",
    "    rank += 1\n",
    "    s += '<tr>'\n",
    "    s += '<th scope=\"row\">'\n",
    "    s += '<p>{}</p>'.format(rank)\n",
    "    s += '</th>'\n",
    "    s += '<td style=\"word-break:break-word;\">'\n",
    "    s += name\n",
    "    if len(paper) > 0:\n",
    "        s += '<a href=\"{}\">[paper]</a>'.format(paper)\n",
    "    if len(code) > 0:\n",
    "        s += '<a href=\"{}\">[code]</a>'.format(code)\n",
    "    s += '<br>'\n",
    "    s += '<strong>{}</strong>'.format(inst)\n",
    "    s += '<br>'\n",
    "    s += date\n",
    "    s += '</td>'\n",
    "    s += '<td>{}</td>'.format(p1)\n",
    "    s += '<td>{}</td>'.format(p2)\n",
    "    s += '<td>{}</td>'.format(p3)\n",
    "    s += '<td>{}</td>'.format(p4)\n",
    "    s += '</tr>'\n",
    "    #print(BeautifulSoup(s).prettify())\n",
    "    #htmlfile.write(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<tr><th scope=\"row\"><p>1</p></th><td style=\"word-break:break-word;\">BERT-PAIR<a href=\"https://www.aclweb.org/anthology/D19-1649.pdf\">[paper]</a><a href=\"https://github.com/thunlp/fewrel\">[code]</a><br><strong>THUNLP, Tsinghua University</strong><br>(Nov 3, 2019)</td><td>77.67</td><td>84.19</td><td>80.31</td><td>86.06</td></tr><tr><th scope=\"row\"><p>2</p></th><td style=\"word-break:break-word;\">Proto (BERT)<br><strong></strong><br>(Nov 3, 2019)</td><td>70.02</td><td>83.79</td><td>45.94</td><td>75.21</td></tr><tr><th scope=\"row\"><p>3</p></th><td style=\"word-break:break-word;\">Proto (CNN)<br><strong></strong><br>(Nov 3, 2019)</td><td>60.59</td><td>77.79</td><td>40.00</td><td>61.66</td></tr>\n"
     ]
    }
   ],
   "source": [
    "print(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
